<template>
  <div v-if="groupCheckSelection.isSelectAll"
       @click="clearCheck" class="el-checkbox is-checked">
    <span class="el-checkbox__input is-checked">
      <span class="el-checkbox__inner"></span>
    </span>
  </div>
  <div class="el-checkbox" v-else @click="select">
    <span class="el-checkbox__input">
      <span class="el-checkbox__inner"></span>
    </span>
  </div>
</template>

<script>
export default {
  name: 'FCheckBoxAll',
  inject: ['groupCheckSelection'],
  props: {
    checkKey: {
      type: String,
      default: undefined
    }
  },
  mounted() {
  },
  methods: {
    clearCheck() {
      let selectedKeys = this.groupCheckSelection.selectedKeys;
      selectedKeys.splice(0, selectedKeys.length);
      this.groupCheckSelection.onChange();
    },
    select() {
      let selectedKeys = this.groupCheckSelection.selectedKeys;
      selectedKeys.splice(0, selectedKeys.length);
      selectedKeys.splice(0, 0, ...this.groupCheckSelection.checkBoxKeySet);
      this.groupCheckSelection.onChange();
    },
  },
};
</script>
